﻿using Vin.Extension.Framework.Aop;
using Vin.Extension.Framework.Dto;
using Vin.Extension.Framework.Entities;
using Vin.Tool.Attributes;

namespace Vin.Extension.Framework.Interface;

[IgnoreService]
public interface IVinFrameworkBaseEntityServiceAsync<TEntity, in TEntityListDto>
    where TEntity : VinFrameworkBaseEntity
    where TEntityListDto : VinFrameworkBaseListDto
{
    Task<List<TEntity>> ListAsync(TEntityListDto dto);

    Task<List<TEntity>> ListAllAsync(TEntityListDto dto, bool checkEnabled = true);

    Task<TEntity?> QueryAsync(long id);

    [VinFrameworkTransaction]
    Task<TEntity?> SaveReturnDataAsync(TEntity entity);

    [VinFrameworkTransaction]
    Task<bool> SaveAsync(TEntity entity);

    [VinFrameworkTransaction]
    Task<bool> SaveAsync(List<TEntity> entities);

    [VinFrameworkTransaction]
    Task<bool> DelAsync(long id);

    [VinFrameworkTransaction]
    Task<bool> EnabledAsync(long id, bool? enabled);
}

[IgnoreService]
public interface IVinFrameworkBaseRecordEntityServiceAsync<TEntity, in TEntityListDto>
    where TEntity : VinFrameworkBaseRecordEntity
    where TEntityListDto : VinFrameworkBaseListDto
{
    Task<List<TEntity>> ListAsync(TEntityListDto dto);

    Task<List<TEntity>> ListAllAsync(TEntityListDto dto, bool checkEnabled = true);

    Task<TEntity?> QueryAsync(long id);

    [VinFrameworkTransaction]
    Task<TEntity?> SaveReturnDataAsync(TEntity entity);

    [VinFrameworkTransaction]
    Task<bool> SaveAsync(TEntity entity);
    
    [VinFrameworkTransaction]
    Task<bool> SaveAsync(List<TEntity> entities);

    [VinFrameworkTransaction]
    Task<bool> DelAsync(long id);

    [VinFrameworkTransaction]
    Task<bool> EnabledAsync(long id, bool? enabled);
}